<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>Vue </title>
    <script src="./js/vue.js"></script>
</head>

<body>
    <div id="app">
        <p>{{ message }}</p>
        <my-component />
    </div>
    <script>
    Vue.component('my-component', {
        template: '<button @click="handleClick">通过父链直接修改数据</button>',
        data: function() {
            return {};
        },
        methods: {
            handleClick: function() {
                this.$parent.message = '修改了';
            }
        }
    });

    new Vue({
        el: '#app',
        data: {
            message: ''
        },
    })
    </script>
</body>

</html>